package za.co.yellowfire.solarflare;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import za.co.yellowfire.solarflare.annotation.Solr;
import za.co.yellowfire.solarflare.annotation.Url;
import za.co.yellowfire.solarflare.log.LogType;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Named;
import java.util.Properties;

/**
 * Provides components for Solar Flare
 * @author Mark P Ashworth
 * @version 0.0.1
 */
@Named
@RequestScoped
public class SearchProvider {
    private static final Logger LOGGER = LoggerFactory.getLogger(LogType.PROVIDER.getCategory());

    /**
     * Provides the Solr URL that should be used
     * @return The Solr URL
     */
    @Produces @Solr @Url
    public String provideSearchUrl() {
        String url = System.getProperty("yellowfire.solr.url", "http://localhost:8080/solr");

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Providing Solr url {}", url);
        }
        return url;
    }
}
